package com.ruoyi.Goover.service.impl;

import java.util.List;

import com.ruoyi.Course.domain.StudyCourse;
import com.ruoyi.Course.service.impl.StudyCourseServiceImpl;
import com.ruoyi.Unit.mapper.StudyUnitMapper;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.token.TokenService;
import org.springframework.stereotype.Service;
import com.ruoyi.Goover.mapper.StudyEnglishMapper;
import com.ruoyi.Goover.domain.StudyEnglish;
import com.ruoyi.Goover.service.IStudyEnglishService;

/**
 * GooverService业务层处理
 * 
 * @author luobom
 * @date 2021-12-02
 */
@Service
public class StudyEnglishServiceImpl implements IStudyEnglishService 
{
    @Autowired
    private StudyEnglishMapper studyEnglishMapper;
    @Autowired
    StudyCourseServiceImpl studyCourseService ;

    /**
     * 查询Goover
     *
     * @param id Goover主键
     * @return Goover
     */
    @Override
    public StudyEnglish selectStudyEnglishById(Long id)
    {        //过滤其它用户的值 改xml文件实在太麻烦了
        StudyEnglish stu=studyEnglishMapper.selectStudyEnglishById(id);
        if(stu!=null) {
            if(!stu.getCreateBy().equals(String.valueOf(SecurityUtils.getUserId()))){
                stu=null;
            }
        }
        return stu;
    }

    /**
     * 查询Goover列表
     * 
     * @param studyEnglish Goover
     * @return Goover
     */
    @Override
    public List<StudyEnglish> selectStudyEnglishList(StudyEnglish studyEnglish)
    {
        //只查当前课程
        //获取课程
        String course=studyCourseService.GetDefaultCourse().getUid();
        //查询课程
        studyEnglish.setCourseuid(course);
        studyEnglish.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return studyEnglishMapper.selectStudyEnglishList(studyEnglish);
    }


    /**
     * 新增Goover
     * 
     * @param studyEnglish Goover
     * @return 结果
     */
    @Override
    public int insertStudyEnglish(StudyEnglish studyEnglish)
    {
        studyEnglish.setCreateTime(DateUtils.getNowDate());
        studyEnglish.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return studyEnglishMapper.insertStudyEnglish(studyEnglish);
    }

    /**
     * 修改Goover
     * 
     * @param studyEnglish Goover
     * @return 结果
     */
    @Override
    public int updateStudyEnglish(StudyEnglish studyEnglish)
    {
        studyEnglish.setUpdateTime(DateUtils.getNowDate());
        studyEnglish.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return studyEnglishMapper.updateStudyEnglish(studyEnglish);
    }

    /**
     * 批量删除Goover
     * 
     * @param ids 需要删除的Goover主键
     * @return 结果
     */
    @Override
    public int deleteStudyEnglishByIds(Long[] ids)
    {
        return studyEnglishMapper.deleteStudyEnglishByIds(ids);
    }

    /**
     * 删除Goover信息
     * 
     * @param id Goover主键
     * @return 结果
     */
    @Override
    public int deleteStudyEnglishById(Long id)
    {
        return studyEnglishMapper.deleteStudyEnglishById(id);
    }
}
